# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity_study_code
File Name: 发票爬去1.py
Author: kij
Create Date: 2021/8/17
https://inv-veri.chinatax.gov.cn/
-------------------------------------------------
"""
import sys
import os
# 为了方便导包
from urllib import parse
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(BASE_DIR)
import base64
import math
import random
import time
import uuid

import execjs
import requests
import re

from PIL import Image
from lxml import etree
import json
from collections import Counter
from module_seven.fpjs.cy import cy
from module_seven.fpjs.yzm import yzm
from module_seven.fpjs.database64 import get_json_base64

# 不同省份地址不一样 beijing
# 测试接口
# http://106.53.31.110:8080/check?fpdm=3100171320&fphm=79262007&date=20170620&code=184553&channel=yd
from predictCaptcha.sdk import *

heads = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36",
}

result_data = {
    "message": "",  # String	结果提示
    "code": "",  # String	0为成功处理
    "time": "",  # String	请求所花费的时间（毫秒）
    "data": "",  # String	解析的数据
    "info": "",  # String	原始数据
}



def yzmQuery(fpdm: str, fphm: str):
    nowtime = str(int(time.time() * 1000))
    data = {
        "fpdm": fpdm,
        "fphm": fphm,
        "nowtime": nowtime,
        "publickey": nowtime,
        "r": random.random(),
        "v": "V2.0.06_009",
        "key9": yzm(fpdm,fphm,nowtime),
    }
    resp = requests.post(
        url=f"{index_url}{yzm_query_url}",
        headers={
            "Connection": "keep-alive",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
            "Sec-Fetch-Site": "none",
            "Sec-Fetch-Mode": "navigate",
            "Sec-Fetch-Dest": "document",
            "Referer": "https://inv-veri.chinatax.gov.cn/",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",

        },
        data=data,
        verify=False,
    )
    res_str = resp.text
    print(res_str)

    res=json.loads(res_str)

    if res.get("data") != None:
        # 解密data数据
        res = json.loads(get_json_base64( res["data"], nowtime))
    print(res)
    print(get_aim_letters(res))
    return res,nowtime



def vatQuery( fpdm: str, fphm: str, date: str, code: str):
    yzmxx,nowtime = yzmQuery(fpdm,fphm)  # 验证码 应该是去后台获取验证码 拿到验证码 需要写方法 key3 key6
    yzm_str = input('请输入验证码00黑01红02黄03蓝:')
    data = {
        'key1': fpdm,  # 发票代码
        'key2': fphm,  # 发票号码
        'key3': date,  # 发票日期
        'key4': code,  # 发票校验码后六位
        # 'kjje': code,  # 发票校验码后六位
        # 'fpje': code,  # 发票校验码后六位
        'fplx': "10",  # 发票类型 01专票 10普通票
        'yzm': yzm_str,
        '_': int(nowtime)+1,  # 验证码时间+1
        'index': yzmxx['key3'],
        'key6': yzmxx['key6'],
        'key9': cy(fpdm, fphm, yzmxx['key2']),
        'yzmSj':  yzmxx['key2'],  # 验证码时间
        'publickey':  yzmxx['key2'],  # 验证码时间
    }

    print(data)
    resp = requests.post(
        url=f"{index_url}{vat_query_url}",
        headers={
            "Connection": "keep-alive",
            "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
            "Sec-Fetch-Site": "none",
            "Sec-Fetch-Mode": "navigate",
            "Sec-Fetch-Dest": "document",
            "Referer": "https://inv-veri.chinatax.gov.cn/",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",

        },
        data=data,
        verify=False,
    )
    res_str = resp.text
    print(res_str)
    res=json.loads(res_str)

    if res.get("data") != None:
        # 解密data数据
        res = json.loads(parse.unquote(get_json_base64( res["data"], yzmxx['key2'])))
        print(f'解密数据{res}')
    print(res)

    # res=json.loads(resp.text)
    # print(res)

def Denoise(img):
    """
    去除噪点
    :param img:加载后图像
    :return img
    """
    imgArray = img.load()
    w, h = img.size
    for i in range(1, h - 1):
        for j in range(1, w - 1):
            count = 0
            if (imgArray[j, i - 1][0] == 255 and imgArray[j, i - 1][1] == 255 and imgArray[j, i - 1][2] == 255):
                count = count + 1
            if (imgArray[j, i + 1][0] == 255 and imgArray[j, i + 1][1] == 255 and imgArray[j, i + 1][2] == 255):
                count = count + 1
            if (imgArray[j - 1, i][0] == 255 and imgArray[j - 1, i][1] == 255 and imgArray[j - 1, i][2] == 255):
                count = count + 1
            if (imgArray[j + 1, i][0] == 255 and imgArray[j + 1, i][1] == 255 and imgArray[j + 1, i][2] == 255):
                count = count + 1
            if (imgArray[j + 1, i + 1][0] == 255 and imgArray[j + 1, i + 1][1] == 255 and imgArray[j + 1, i + 1][
                2] == 255):
                count = count + 1
            if (imgArray[j + 1, i - 1][0] == 255 and imgArray[j + 1, i - 1][1] == 255 and imgArray[j + 1, i - 1][
                2] == 255):
                count = count + 1
            if (imgArray[j - 1, i - 1][0] == 255 and imgArray[j - 1, i - 1][1] == 255 and imgArray[j - 1, i - 1][
                2] == 255):
                count = count + 1
            if (imgArray[j - 1, i + 1][0] == 255 and imgArray[j - 1, i + 1][1] == 255 and imgArray[j - 1, i + 1][
                2] == 255):
                count = count + 1

            if count > 6:
                # 如果一个点周围八个点有七个是空白，认为该点也应该是空白
                img.putpixel((j, i), (255, 255, 255))

    # 下面两个循环将图片最边缘一圈全部涂白
    for i in range(w):
        img.putpixel((i, 0), (255, 255, 255))
        img.putpixel((i, h - 1), (255, 255, 255))

    for i in range(h):
        img.putpixel((0, i), (255, 255, 255))
        img.putpixel((w - 1, i), (255, 255, 255))

    return img


def Cut(img):
    '''
    将图片按字符切开
    :param img:
    :return index: 所需字符在所有字符中的索引值
    '''
    index = []
    child_img_list = []
    w, h = img.size
    startEdge = []
    endEdge = []
    blackdotsEachColumn = []
    count0 = 0
    imgArray = img.load()
    for x in range(w):
        for y in range(h):
            if (imgArray[x, y] == (0, 0, 0)):
                count0 = count0 + 1
        # 变量blackDotsEachColumn记录下来每一列的黑点数量
        blackdotsEachColumn.append(count0)
        count0 = 0

    # 选定除了边框外的每一列，遍历查找字符的边缘列，每一个起始边缘都有一个对应的结束边缘
    for x in range(1, w - 1):
        # 从左到右，遍历查找起始边缘
        if (blackdotsEachColumn[x - 1] == 0 and blackdotsEachColumn[x] != 0):
            startEdge.append(x)
        # 从左到右，遍历查找结束边缘
        if (blackdotsEachColumn[x] != 0 and blackdotsEachColumn[x + 1] == 0):
            endEdge.append(x)

    # 归并本该在一起的部分
    for i in range(len(startEdge)):
        # 如果一个块太小，可以认为它属于前一个或后一个块
        if ((i < (len(startEdge) - 1)) and len(startEdge) >= 1):  # 如果只有一个起始边缘，就不需要归并了

            # 第一个块没有前一个块，所以如果横向纵向都太小的话，认为跟后一个块是一体的
            if (i == 0 and ((endEdge[i] - startEdge[i]) <= 3) and (blackdotsEachColumn[startEdge[i]] <= 2) and (
                    blackdotsEachColumn[endEdge[i]] <= 2)):
                startEdge.pop(i + 1)
                endEdge.pop(i)
                continue

            if (i != 0 and ((endEdge[i] - startEdge[i]) <= 3) and (blackdotsEachColumn[startEdge[i]] <= 2) and (
                    blackdotsEachColumn[endEdge[i]] <= 2)):

                # 可以认为这个小块是属于前面或者后面的一个块，根据前后距离判断是属于哪个
                if ((startEdge[i + 1] - endEdge[i]) < (startEdge[i] - endEdge[i - 1])):
                    startEdge.pop(i + 1)
                    endEdge.pop(i)
                    continue

                else:
                    startEdge.pop(i)
                    endEdge.pop(i - 1)
                    continue

    tmp1 = startEdge
    tmp2 = endEdge

    # 同样颜色的字符可能粘连，按平均宽度15切开
    for i in range(len(startEdge)):
        # 取每一个块的宽度
        blockWidth = endEdge[i] - startEdge[i]
        if (blockWidth > 15):
            p = math.ceil(blockWidth / 15)  # 向上取整
            for j in range(1, p):
                k = int(startEdge[i] + j * blockWidth / p)
                tmp1.append(k)
                tmp2.append(k)

    # 从小到大排序
    tmp1.sort()
    tmp2.sort()

    startEdge = tmp1
    endEdge = tmp2
    print(startEdge)
    print(endEdge)
    num = 0
    for i in range(len(startEdge)):
        if (startEdge[i] > 0 and startEdge[i] < 16) and (endEdge[i] > 13 and endEdge[i] < 30):
            if (num <= 0):
                index.append(0)
            else:
                index.append(num)

        elif (startEdge[i] > 13 and startEdge[i] < 22) and (endEdge[i] > 24 and endEdge[i] < 40):

            if (num <= 1):
                index.append(1)
            else:
                index.append(num)

        elif (startEdge[i] > 25 and startEdge[i] < 35) and (endEdge[i] > 35 and endEdge[i] < 50):
            if (num <= 2):
                index.append(2)
            else:
                index.append(num)

        elif (startEdge[i] > 40 and startEdge[i] < 48) and (endEdge[i] > 48 and endEdge[i] < 58):
            if (num <= 3):
                index.append(3)
            else:
                index.append(num)

        elif (startEdge[i] > 50 and startEdge[i] < 58) and (endEdge[i] > 60 and endEdge[i] < 70):
            if (num <= 4):
                index.append(4)
            else:
                index.append(num + 1)
        elif (startEdge[i] > 60 and startEdge[i] < 75) and (endEdge[i] > 70 and endEdge[i] < 90):
            if (num <= 5):
                index.append(5)
            else:
                index.append(num)
        else:
            index.append(num)
        num += 1
    return index


def Thresholding(picpath):
    '''
    二值化，取出想要的文字部分
    :param picpath: 验证码图片的文件路径
    :return img: 加载后图像
    '''

    img = Image.open(picpath)
    imgArray = img.load()

    x, y = img.size

    # 对于不同的验证码二值化不同的字符
    if 'red' in str(picpath):
        for i in range(y):
            for j in range(x):
                if (imgArray[j, i][0] > 200 and imgArray[j, i][1] < 110 and imgArray[j, i][2] < 100
                        and (imgArray[j, i][2] + imgArray[j, i][1]) < imgArray[j, i][0]):
                    img.putpixel((j, i), (0, 0, 0))
                else:
                    img.putpixel((j, i), (255, 255, 255))

    elif 'blue' in str(picpath):
        for i in range(y):
            for j in range(x):
                if (imgArray[j, i][0] < 100 and imgArray[j, i][1] < 100 and imgArray[j, i][2] > 200 or (
                        imgArray[j, i][0] + imgArray[j, i][1]) < imgArray[j, i][2]):
                    img.putpixel((j, i), (0, 0, 0))
                else:
                    img.putpixel((j, i), (255, 255, 255))

    elif 'yellow' in str(picpath):
        for i in range(y):
            for j in range(x):
                if (imgArray[j, i][0]
                        > 200 and imgArray[j, i][1] > 200 and imgArray[j, i][2] < 110):
                    img.putpixel((j, i), (0, 0, 0))
                else:
                    img.putpixel((j, i), (255, 255, 255))

    else:
        for i in range(y):
            for j in range(x):
                if (imgArray[j, i][0] < 125 and imgArray[j, i][1] < 125 and imgArray[j, i][2] < 125 and (
                        imgArray[j, i][0] * 0.21267 + imgArray[j, i][1] * 0.71516 + imgArray[j, i][2] * 0.067) < 125):
                    img.putpixel(
                        (j, i), (0, 0, 0))
                else:
                    img.putpixel((j, i), (255, 255, 255))

    return img


def predict_all_letter(picpath):
    """
    预测图像所包含全部字符
    :param picpath: 图像路径
    :return 预测字符
    """
    sdk = SDK(r"predictCaptcha/model/Captcha-CNNX-NoRecurrent-H64-CrossEntropy-C3_model.yaml")

    with open(picpath, "rb") as f:
        pic = f.read()

    predict_condition = []
    for i in range(1000):
        predict_condition.append(sdk.predict(pic))
    print(Counter(predict_condition).most_common(1))
    return Counter(predict_condition).most_common(1)


def change_image_channels(picpath):
    """
    调整图像通道数
    :param picpath 图片路径
    """
    image = Image.open(picpath)
    if image.mode == 'RGBA':
        r, g, b, a = image.split()
        image = Image.merge("RGB", (r, g, b))
        image.save(picpath)


def get_aim_letters(captcha_data):
    """
    获取目标条件字符
    :param captcha_json: json数据 ，包括图片base64、目标颜色
    :return aim_letter: 目标字符
    """
    # 图片base64文件字符串
    captcha_base64 = captcha_data["key1"]
    # 验证码中字符所对应的颜色
    captcha_type = captcha_data["key4"]
    picpath = "./temp/" + captcha_type + "_" + str(uuid.uuid1()) + ".png"
    # 保存base64图片在本地
    captcha_base64 = base64.b64decode(captcha_base64)  # 去除前缀
    file = open(picpath, 'wb')
    file.write(captcha_base64)
    file.close()
    # 拿到文件图片
    change_image_channels(picpath)
    all_letters = predict_all_letter(picpath)
    # print("all:", all_letters[0])

    pic = Thresholding(picpath)
    pic = Denoise(pic)
    index_sequence = Cut(pic)
    # print(index_sequence)

    aim_letter = ""
    # for i in index_sequence:
    #     aim_letter += all_letters[0][0][i]
    # os.remove(picpath)
    print(aim_letter)
    return aim_letter


# index_url = "https://fpcy.shanghai.chinatax.gov.cn:1001/NWebQuery/"
# index_url = "https://fpcy.shenzhen.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.jiangsu.chinatax.gov.cn:80/NWebQuery/"
# index_url = "https://fpcy.jiangxi.chinatax.gov.cn:82/NWebQuery/"
# index_url = "https://fpcy.heilongjiang.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.hebei.chinatax.gov.cn/NWebQuery/"
# index_url = "https://fpcy.fujian.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.beijing.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.tjsat.gov.cn/NWebQuery/"
# index_url = "https://fpcy.ningbo.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.xiamen.chinatax.gov.cn/NWebQuery/"
# index_url = "https://fpcy.qingdao.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.zhejiang.chinatax.gov.cn/NWebQuery/"
# index_url = "https://fpcy.guangdong.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.anhui.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.chongqing.chinatax.gov.cn:80/NWebQuery/"
# index_url = "https://fpcy.gansu.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.guangxi.chinatax.gov.cn:8200/NWebQuery/"
# index_url = "https://fpcy.guizhou.chinatax.gov.cn:80/NWebQuery/"
# index_url = "https://fpcy.hainan.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.henan.chinatax.gov.cn/NWebQuery/"
# index_url = "https://fpcy.hubei.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.hunan.chinatax.gov.cn:8083/NWebQuery/"
# index_url = "https://fpcy.jilin.chinatax.gov.cn:4432/NWebQuery/"
# index_url = "https://fpcy.liaoning.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.neimenggu.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.ningxia.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.qinghai.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.shandong.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.shanxi.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.shaanxi.chinatax.gov.cn:443/NWebQuery/"
# index_url = "https://fpcy.sichuan.chinatax.gov.cn:443/NWebQuery/"
index_url = "https://fpcy.yunnan.chinatax.gov.cn:443/NWebQuery/"
vat_query_url = "vatQuery?"  # 校验验证码
yzm_query_url = "yzmQuery?"  # 获取验证码

if __name__ == "__main__":
    # 上海增值税普通发票 验证码接口失败
    # vatQuery("031001900204", '60015736', "20210819", "953166")
    # 江苏增值税普通发票 验证码接口失败
    # vatQuery("032002100304", '26052331', "20210816", "908574")
    # 河北增值税普通发票
    # vatQuery("013002100104", '02633648', "20210819", "589670")
    # vatQuery("1100184130", '14577173', "20210824", "413441")
    # 黑龙江增值税普通发票
    # vatQuery("023002100111", "26651360", "20210903", "080957")
    # 甘肃 增值税普通发票 失败
    # vatQuery("062001700111", "24845376", "20201201", "031027")
    # 广西 增值税普通发票 失败
    # vatQuery("045001600111", "00000778", "20160627", "884515")
    # 江西 普票
    # vatQuery("036002100104", "23031462", "20210812", "715022")
    # 青海 普票
    # vatQuery("063001700112", "00000024", "20180101", "327552")
    # 四川 普票
    # vatQuery("251001330111", "11410067", "20160612", "795933")
    # 云南 普票
    # vatQuery("153001414098", "02570928", "20160409", "882666")

    # 北京普通发票
    # vatQuery("011002100111", "78490309", "20210824", "266592")
    # vatQuery("011002100111", "78490307", "20210824", "279480")
    # vatQuery("031002000511", "23123134", "20201214", "906363")
    # 北京增值税专用发票 成功 {"key1":"001","key2":"0≡20210824≡北京市金宏亚五金交电有限责任公司≡9112011159871826XH≡天津市北辰科技园区华信道8号022-87987910≡中国民生银行股份有限公司天津梅江支行 2108012830002667≡天津敏驰汽车部品有限公司≡9111010270012715X9≡西城区骡马市大街临字31-3号 63042862≡中国工商银行北京菜市口支行0200001809067033605≡3929.92≡30230.08≡34160≡≡661402114711≡0≡75167495833641231876≡0≡99","key3":"*密封用填料*胶水█94#█桶█12█676.991150442477876█8123.89█13.0█1056.11█1070212030000000000≡*塑料制品*塑料瓶██个█500█0.884955752212389█442.48█13.0█57.52█1070601090000000000≡*密封用填料*胶水█94#█桶█12█676.991150442477876█8123.89█13.0█1056.11█1070212030000000000≡*密封用填料*胶水█94#█桶█12█676.991150442477876█8123.89█13.0█1056.11█1070212030000000000≡*密封用填料*胶水█94#█桶█8█676.991150442477876█5415.93█13.0█704.07█1070212030000000000","key4":"","key5":"1","key11":"r","key12":"93E4MGgcNWxbMzVyMqA4"}
    # vatQuery("1100184130", "14577173", "20210824", "30230.08")
    # 天津增值税专用发票 成功 {'key1': '001', 'key2': '3≡20210902≡广州福耀玻璃有限公司≡91440183788918844K≡广州增城市新塘镇荔新公路段 32876000≡中国银行广州增城新塘支行 673057746445≡天津敏驰汽车部品有限公司≡9112011159871826XH≡天津市北辰科技园区华信道8号022-87987910≡中国民生银行股份有限公司天津梅江支行2108012830002667≡34952.19≡4543.78≡39495.97≡≡499908151293≡499908151293≡13540203769583227427≡0≡99', 'key3': '*交通运输设备*包边条█BRA3149█条█7350█4.7554█34952.19█13.0█4543.78█1090310019900000000', 'key4': '', 'key5': '1', 'key11': 'r', 'key12': '74A6NGEdNqR6NTt2MaI8'}
    # vatQuery("1200212130", '01674067', "20210902", "34952.19")
    # 增值税普通发票测试成功
    # vatQuery("012002000411", '74123680', "20210813", "407961")
    # 上海专票 {"key1":"001","key2":"0≡20210310≡德州敏驰汽车零部件有限公司≡913714286980861088≡武城县经济开发区 0534-5077618≡中国农业银行股份有限公司武城县支行 15779101040009511≡上海崇乾质量技术服务有限公司≡91310120MA1HM76G23≡上海市奉贤区青高路368号3幢2297室 18972650597≡建设银行上海六灶支行31050181440000000314≡660≡39.6≡699.6≡≡661704943048≡0≡57067376491803301969≡0≡99","key3":"*现代服务*服务费███1█660█660█6.0█39.6█3049900000000000000","key4":"","key5":"1","key11":"r","key12":"27AbNWk8OWp8LTN3NGEc"}
    # vatQuery("3100204130", '07384487', "20210310", "660.00")
    # 江苏增值税专用发票 成功 {"key1":"001","key2":"0≡20210427≡江苏金陵奥普特高分子材料有限公司≡913714286980861088≡武城县经济开发区 0534-5077618≡中国农业银行股份有限公司武城县支行 15779101040009511≡德州敏驰汽车零部件有限公司≡913211835668522371≡句容经济开发区北三环以北 0511-87338800-8039≡中行句容支行 461158202452≡1088.82≡8375.5≡9464.32≡≡661511545326≡0≡62110046053589768086≡0≡99","key3":"*化学合成材料*热塑性弹性体█6375N-03-YT█公斤█350█23.93█8375.5█13.0█1088.82█1070213020000000000","key4":"","key5":"1","key11":"r","key12":"85gbMGQcNaNbMDR2NWc4"}
    # vatQuery("3200211130", '07610196', "20210427", "8375.50")
    # 河北增值税电子普通票 测试成功 {"key1":"001","key2":"0≡20210814≡河北雪松纸业有限公司≡91130607776150444E≡保定市满城区大册营造纸工业园区7132261≡中国建设银行满城支行13001667108050508325≡天津敏驰汽车部品有限公司≡9112011159871826XH≡≡≡06580668589660413441≡9.57≡83.2≡≡929905977513≡73.63≡0≡≡","key3":"*纸制品*卫生纸██提█13.0█18.40708█73.63█4█9.57██1060105040000000000","key4":"","key5":"1","key11":"r"}
    # vatQuery("013001620011", '85314630', "20210814", "413441")
    # 福建增值税专用发票 测试成功 {"key1":"001","key2":"0≡20210811≡天津敏驰汽车部品有限公司≡9112011159871826XH≡天津市北辰科技园区华信道8号  022-87987910≡中国民生银行股份有限公司天津梅江支行  2108012830002667≡福州富诚胶粘制品有限公司≡913501217869233165≡福建省福州市闽侯县青口镇新城西路16路4#厂房 0591-22789869≡中国银行闽侯青口支行 426058362331≡12665.4≡1646.5≡14311.9≡≡661514727871≡0≡60715875921085466956≡0≡99","key3":"*塑料制品*双面胶带█71*33█卷█50█178.068█8903.4█13.0█1157.44█1070601990000000000≡*塑料制品*双面胶带█150*33█卷█10█376.20█3762█13.0█489.06█1070601990000000000","key4":"","key5":"1","key11":"r","key12":"80c4MqA5NGp6NTR5OWY6"}
    # vatQuery("3500212130", '02238931', "20210811", "12665.40")
    # 宁波增值税专用发票 成功 {"key1":"001","key2":"1≡20210825≡余姚市欣雯机械有限公司≡9112011159871826XH≡天津市北辰科技园区华信道8号022-87987910≡中国民生银行股份有限公司天津梅江支行2108012830002667≡天津敏驰汽车部品有限公司≡91330281066607294D≡余姚市朗霞街道新新村 0574-62189388≡余姚市合作银行朗霞支行201000106652814≡2249.12≡17300.88≡19550≡≡661536642270≡0≡44398269653755185920≡0≡99","key3":"*交通运输设备*铁杆█G830█只█23000█0.752212389380531█17300.88█13.0█2249.12█1090310010100000000","key4":"","key5":"1","key11":"r","key12":"90I7Mqc4NWJ8MjRxOWU8"}
    # vatQuery("3302212130", '04370321', "20210825", "17300.88")
    # 厦门增值税专用发票 成功 {"key1":"001","key2":"0≡20210827≡天津敏驰汽车部品有限公司≡9112011159871826XH≡天津市北辰科技园区华信道8号　87987910≡中国民生银行股份有限公司天津梅江支行　2108012830002667≡厦门丰润兴工贸有限公司≡91350213705419477N≡厦门市集美区石星路332号1楼 0592-7292902≡兴业银行厦门观音山支行  129960100100288763≡1460≡189.8≡1649.8≡≡661516448971≡0≡59848877991774101788≡0≡99","key3":"*密封用填料*助拨胶带█C90014-09█片█50000█0.029200000000000█1460█13.0█189.8█1070212030000000000","key4":"订单号:22704210724<br/>        限转账支付","key5":"1","key11":"r","key12":"50IaMGYbMGB6MDJxNGEc"}
    # vatQuery("3502212130", '00506333', "20210827", "1460.00")
    # 青岛增值税专用发票 成功 {'key1': '001', 'key2': '0≡20210828≡青岛开霖电子科技有限公司≡9112011159871826XH≡天津市北辰科技园区华信道8号022-87987910≡中国民生银行股份有限公司天津梅江支行2108012830002667≡天津敏驰汽车部品有限公司≡91370214MA3P14J105≡山东省青岛市城阳区仙山东路16号 18663974013≡招商银行股份有限公司城阳支行   532908543010508≡2085.18≡16039.82≡18125≡≡661900797455≡0≡62440247242525923704≡0≡99', 'key3': '*塑料制品*双面胶带█角部胶带C90174-1A█个█30040█0.18█5407.2█13.0█702.94█1070601990000000000≡*塑料制品*双面胶带█角部胶带C90174-2A█个█30040█0.14█4205.6█13.0█546.73█1070601990000000000≡*塑料制品*双面胶带█TDC胶带加工█个█145250█0.044248█6427.02█13.0█835.51█1070601990000000000', 'key4': '', 'key5': '1', 'key11': 'r', 'key12': '36Y5OGk4NGJ4Nzx1NqU6'}
    # vatQuery("3702212130", '02425767', "20210828", "16039.82")
    # 浙江增值税专用发票 成功 {"key1":"001","key2":"0≡20210803≡天津敏驰汽车部品有限公司≡9112011159871826XH≡天津市北辰科技园区华信道8号≡中国民生银行股份有限公司天津梅江支行  2108012830002667≡浙江万马泰科新材料有限公司≡91330185MA28NQWN6H≡浙江省临安市青山湖街道景观大道81号0571-63870153≡浦发银行临安支行95080154740019557≡35190≡4574.7≡39764.7≡≡499932720898≡499932720898≡02222745810755923365≡0≡99","key3":"*橡胶制品*热塑性硫化橡胶█121-67█吨█1.5█23460█35190█13.0█4574.7█1070599000000000000","key4":"","key5":"1","key11":"r","key12":"43I8OWk8MqNdNDBzOWg4"}
    # vatQuery("3300211130", '19509564', "20210803", "35190.00")
    # 黑龙江专用发票 成功 {"key1":"001","key2":"148≡20180501≡牡丹江百货有限责任公司≡23109067749425X≡黑龙江省牡丹江市东安区太平路95号0453-6991063≡中国工商银行牡丹江市分行长安街支行0903020209201066870≡哈尔滨家乐福超市有限公司牡丹江太平路店≡91231000711095341K≡爱民区新华路268号 0453-6562002≡中国工商银行牡丹江新华路支行  0903020319201076272≡160.34≡1002.16≡1162.50≡≡661517197300≡0.00≡52793069353118556953≡2≡99","key3":"*美容护肤品*美宝莲 持久魅影眼线膏 棕色█5g█支█15█21.551724137931036█323.28█0.160█51.72█1070223040000000000≡*美容护肤品*美宝莲眼部及唇部卸妆液█5ml█支█35█19.396551724137932█678.88█0.160█108.62█1070223040000000000","key4":"","key5":"1","key11":"o","key12":"64E7MGU4OGVdLDRxMaca"}
    # vatQuery("2300163130", "00313196", "20180501", "1002.16")
    # 广东增值税普通发票 成功 {"key1":"001","key2":"0≡20210605≡广州从化苏宁易购销售有限公司≡91440101MA5CYY5J2R≡广州市从化区明珠工业园明珠大道北63号二层自编之60 020-28381999≡中国建设银行股份有限公司广州从化支行 44050156160100002190≡果果跳动（北京）互联网科技有限公司≡91110105MA01QNWR7Q≡≡≡49159623150783797402≡323.12≡2808.72≡≡661938377499≡2485.6≡0≡≡","key3":"*移动通信设备*通信器材及配件█DT2002C█件█13.0█2565.48672566█2565.49█1.00000000█333.51██1090505010000000000≡*移动通信设备*通信器材及配件███13.0██-243.14██-31.61██1090505010000000000≡*移动通信设备*通讯手机全保修服务计划3年(2500-3999)██件█13.0█246.90265487█246.9█1.00000000█32.1██1090505010000000000≡*移动通信设备*通讯手机全保修服务计划3年(2500-3999)███13.0██-83.65██-10.88██1090505010000000000","key4":"35482520942","key5":"1","key11":"r"}
    # vatQuery("044002000611", "59071693", "20210605", "797402")
    # 安徽省增值税专用发票 成功 {"key1":"001","key2":"0≡20210420≡合肥罗麦焊割辅具制造有限公司≡913714286980861088≡武城县经济开发区≡中国农业银行股份有限公司武城县支行 15779101040009511≡德州敏驰汽车零部件有限公司≡91340100MA2TRQRM78≡合肥市新站区淮海大道1188号京商商贸城G区商业GG103室 13855409126≡徽商银行股份有限公司合肥宁国路支行  223019578081000002≡230.2≡1770.8≡2001≡≡661908409921≡0≡45071749594172388238≡0≡99","key3":"*交通运输设备*手推车██台█3█590.265486725663717█1770.8█13.0█230.2█1090328010000000000","key4":"","key5":"1","key11":"r","key12":"20g9OGM9NqZbMjp1OGU6"}
    # vatQuery("3400211130", "02278559", "20210420", "1770.80")
    # 重庆增值税专用发票 成功 {"key1":"001","key2":"0≡20210524≡德州敏驰汽车零部件有限公司≡913714286980861088≡武城县经济开发区       0534-5077618≡中国农业银行股份有限公司武城县支行 15779101040009511≡重庆市焱南物资有限公司≡9150010855900474XB≡重庆市南岸区南坪西路38号2栋15-8号 62600238≡中国工商银行重庆市南岸支行 3100027009200048658≡16302≡2119.26≡18421.26≡≡661511472147≡0≡75864799971844057813≡0≡99","key3":"*化学合成材料*粘接用表面处理剂RC1017█3kg/桶█公斤█72█133.3334█9600█13.0█1248█1070213070000000000≡*橡胶制品*胶带AFB4540G█4mm*66m█卷█300█22.34█6702█13.0█871.26█1070504020000000000","key4":"","key5":"1","key11":"r","key12":"28E4MWM5NqR6Mzp2NqA4"}
    # vatQuery("5000203130", "03956636", "20210524", "16302.00")
    # 贵州 增值税普通发票 成功 {"key1":"001","key2":"2≡20190617≡盘州市宏利通出租客运有限公司≡91520222MA6ECN2B1M≡贵州省六盘水市盘州市亦资街道九头山社区四组08583100568≡中国建设银行股份有限公司盘州支行52050163613600000801≡杨庆羽≡ ≡≡≡68483499253076549943≡0.15≡5.00≡≡661837998579≡4.85≡0≡≡","key3":"*运输服务*客运服务费███0.030█4.85436893█4.85█1.00000000█0.15██3010101020203000000","key4":"","key5":"1","key11":"o"}
    # vatQuery("052001600211", "00148976", "20190617", "549943")
    # 海南增值税普通发票 成功 {"key1":"001","key2":"10≡20170801≡海南省烟草公司海口公司≡91460100201295861Y≡海南省海口市秀英区南海大道174号 0898-68607521≡中国农业银行海口华海支行 21-107001040017659≡李民≡ ≡海南省海口市得胜沙路68号东侧面 66238184≡≡55473298901084207376≡311.89≡2146.50≡≡661620025063≡1834.61≡0≡≡","key3":"椰王██条█0.170█122.30769231█366.92█3.00000000█62.38██1030403010000000000≡苏烟(五星红杉树)██条█0.170█161.26495726█161.26█1.00000000█27.42██1030403010000000000≡芙蓉王（硬）██条█0.170█186.63247863█1306.43█7.00000000█222.09██1030403010000000000","key4":"","key5":"1","key11":"o"}
    # vatQuery("046001600111", "02032876", "20170801", "207376")
    # 河南增值税专用发票 成功 {"key1":"001","key2":"0≡20210507≡德州敏驰汽车零部件有限公司≡913714286980861088≡武城县经济开发区0534-5077618≡中国农业银行股份有限公司武城县支行15779101040009511≡河南华洋电工科技集团有限公司≡914107217066142661≡新乡经济技术集聚区远大路西段0373-7088558≡中国工商银行股份有限公司新乡支行1704220219201148807≡19119.52≡2485.54≡21605.06≡≡499910235752≡499910235752≡11994864510292002898≡0≡99","key3":"*有色金属冶炼压延品*高效节能电机专用绕组线(130级圆线)█φ0.41-0.50█kg█299.13█63.9171000029881█19119.52█13.0█2485.54█1080301000000000000","key4":"","key5":"1","key11":"r","key12":"71gaOGMdOGF9NTRzMqI6"}
    # vatQuery("4100211130", "14808330", "20210507", "19119.52")
    # 湖北专用发票 成功 {"key1":"001","key2":"0≡20210805≡湖北力塔金属制品有限公司≡91420982MA495GXDX7≡湖北省安陆市南城街道办事处草庙村三组（村委会） 0712-5287910≡中国农业银行股份有限公司安陆支行府城分理处 1751 4601 0400 0340 6≡湖北敏驰汽车部品有限公司≡91420982MA4943XF59≡安陆市李店镇紫阳一街西103-2号13764566889≡中国建设银行股份有限公司安陆太白支行42050168623600000142≡2981.95≡22938.05≡25920≡≡497004075014≡0≡09821244579279280165≡0≡99","key3":"*金属制品*隔断█0.8米*135米█平方█108█132.743362831858█14336.28█13.0█1863.72█1080424000000000000≡*金属制品*隔断█1.2米*43.3米█平方█51.6█132.743362831858█6849.56█13.0█890.44█1080424000000000000≡*金属制品*隔断门█3米*1.2米█个█2█876.106194690266█1752.21█13.0█227.79█1080424000000000000","key4":"","key5":"1","key11":"r","key12":"82EcOWQ9NGt5MjZ3OWkc"}
    # vatQuery("4200194130", "10551394", "20210805", "22938.05")
    # 湖南增值税专用发票 成功 {"key1":"001","key2":"0≡20210729≡德州敏驰汽车零部件有限公司≡913714286980861088≡武城县经济开发区 0534-5077618≡中国农业银行股份有限公司武城县支行 1577 9101 0400 0951 1≡长沙宇亨酒店管理有限公司≡91430104MA4R4HGQ1N≡湖南省长沙市岳麓区观沙岭街道滨江路53号楷林国际大厦C座20楼20020731-89921888≡湖南三湘银行股份有限公司0070010101000002483≡1273.27≡12.73≡1286≡≡499959015460≡499959015460≡10537586558313087152≡0≡99","key3":"*住宿服务*住宿费██天█2█636.633663366337█1273.27█1.0█12.73█3070402000000000000","key4":"","key5":"1","key11":"r","key12":"93k9MGQ4NWJ6MzN0NGga"}
    # vatQuery("4300204130", "07285333", "20210729", "1273.27")
    # 吉林增值税专用发票 成功 {"key1":"001","key2":"0≡20201228≡德州敏驰汽车零部件有限公司≡913714286980861088≡武城县经济开发区 0534-5077618≡中国农业银行股份有限公司武城县支行 1577 9101 1040 0095 11≡上海锦江国际旅馆投资有限公司长春分公司≡912201016616090595≡长春市经开区会展大街1111号043185831238≡工行珠海路支行4200204819000003758≡728.3≡43.7≡772≡≡929906301241≡929906301241≡09410859163410744673≡0≡99","key3":"*住宿服务*住宿█████728.3█6.0█43.7█3070402000000000000","key4":"","key5":"1","key11":"r","key12":"39A6OGIaNaF8NTNyNaU8"}
    # vatQuery("2200193160", "02359735", "20201228", "728.30")
    # 辽宁 专票 {"key1":"001","key2":"0≡20210528≡德州敏驰汽车零部件有限公司≡913714286980861088≡武城县经济开发区0534-5077618≡中国农业银行股份有限公司武城县支行 15779101040009511≡沈阳泽优设备检测技术服务有限公司≡91210113MA0Y71BN7X≡沈阳市沈北新区建设北一路30号15840258689≡建设银行沈阳虎石台支行21050149360100000391≡1643.56≡16.44≡1660≡≡539909753062≡539909753062≡03599246594431002766≡0≡99","key3":"*其他咨询服务*筛选服务费█████1643.56█1.0█16.44█3040603990000000000","key4":"","key5":"1","key11":"r","key12":"40AdNWEaOWJ8MjRwMWk4"}
    # vatQuery("2100194130", "07932391", "20210528", "1643.56")
    # 内蒙古 专票 {"key1":"001","key2":"215≡20190401≡中电投霍林河煤电集团铝业股份有限公司≡91150000115810409A≡内蒙古通辽市科尔沁区东郊工业园区 0475-8437184≡中行通辽分行 150804264685≡内蒙古好运来商贸有限公司≡91150500MA0MWNKE6N≡内蒙古自治区通辽市科尔沁区民航路五金建筑装饰材料城5#楼1-2层109室13327046160≡内蒙古银行股份有限公司通辽分行102901201090071761≡0.92≡0.08≡1.00≡≡929907897517≡0.00≡≡2≡99","key3":"*谷物加工品*大米█████0.92█0.090█0.08█1030102010100000000","key4":"","key5":"1","key11":"o","key12":"65M6NaY4OWp9LDt3MqI8"}
    # vatQuery("1500173130", "02806007", "20190401", "0.92")
    # 宁夏 普通发票 {"key1":"001","key2":"1≡20210408≡宁夏昊骏石油化工有限公司≡91640300MA76HA048J≡吴忠市利通区吴惠公路西侧古青高速杨马湖收费站南侧13895458800≡工行吴忠市支行2903021019200104260≡宁夏宝丰能源集团股份有公司≡91640000774917806≡宁夏银川市宁东能源化工基地宝丰循环经济工业园区09516881268≡中国建设银行银川黄河西路支行6400122100059988888≡70712638841565417362≡52.81≡459≡≡661024136197≡406.19≡0≡08≡","key3":"*汽油*95#车用汽油（VIA）██升█13.0█6.08849558█406.19█66.71511628█52.81██1070101010100000000","key4":"","key5":"1","key11":"r"}
    # vatQuery("064001600111", "55873649", "20210408", "417362")
    # 山东 专用票 {"key1":"001","key2":"0≡20210326≡德州迅诚汽模科技有限公司≡913714286980861088≡武城县经济开发区 0534-5077618≡中国农业银行股份有限公司武城县支行 15779101040009511≡德州敏驰汽车零部件有限公司≡91371402095103212Y≡山东省德州市德城区天衢办事处学院东路以东德州东北城五金一区4号楼1-2层22号2层 13905349522≡德州银行天衢中路支行 809250101421003697≡46.2≡4620≡4666.2≡≡661002853574≡0≡54743624743324839843≡0≡99","key3":"*劳务*模具费██套█6█770.000000000000000█4620█1.0█46.2█2020000000000000000","key4":"","key5":"1","key11":"r","key12":"28g9MGQcMat5Nzp4MaQa"}
    # vatQuery("3700201130", "20902783", "20210326", "4620.00")
    # 山西 专票 {"key1":"001","key2":"0≡20210221≡德州敏驰汽车零部件有限公司≡913714286980861088≡武城县经济开发区 0534-5077618≡中国农业银行股份有限公司武城县支行 15779101040009511≡太原德邦物流有限公司≡9114010969427892XM≡太原市万柏林区千峰南路大王小区北区18幢8号 18503431935≡中国工商银行股份有限公司太原下元支行 0502126309200011064≡61.32≡3.68≡65≡≡499098868478≡499098868478≡02751424017293898099≡0≡99","key3":"*物流辅助服务*收派服务███1█61.32█61.32█6.0█3.68█3040409030000000000","key4":"","key5":"1","key11":"r","key12":"42AdMqU7Mqp4Njt5MaEc"}
    # vatQuery("1400204130", "00599838", "20210221", "61.32")
    # 陕西 普票 {"key1":"001","key2":"0≡20170703≡陕西省数字证书认证中心股份有限公司≡91610000755214162L≡西安市高新区高新三路九号信息港大厦七层701室02988314905≡122310001430400≡西安市西京机械厂≡610112220894894≡徐家湾渭滨街10号029-88348253≡≡06120200923105309164≡16.98≡300.00≡≡499098828812≡283.02≡0≡≡","key3":"CA证书服务费███0.060█283.02█283.02█1█16.98██3040201990000000000","key4":"","key5":"1","key11":"o"}
    # vatQuery("061001605111", "14140115", "20170703", "309164")
    # 深圳 专票 {"key1":"001","key2":"0≡20210325≡深圳市星弈环保科技有限公司≡913714286980861088≡武城县经济开发区 0534-5077618≡中国农业银行股份有限公司武城县支行 15779101040009511≡德州敏驰汽车零部件有限公司≡91440300076912022P≡深圳市宝安区燕罗街道塘下涌社区创新路罩山工业区厂房1栋厂房1栋50107559956135≡中国工商银行深圳福园支行4000023509200162760≡736.28≡5663.72≡6400≡≡499913358707≡499913358707≡11331261590227972885≡0≡99","key3":"*软件*空气净化器控制系统V2.0█XY-01█台█4█566.371681415929█2265.49█13.0█294.51█1060301020100000000≡*通用设备*烟雾净化器█XY-01█台█4█849.557522123894█3398.23█13.0█441.77█1090130010000000000","key4":"","key5":"1","key11":"r","key12":"62Y6OGU4NWF5MzJ2NGk8"}
    # vatQuery("4403204130", "10779631", "20210325", "5663.72")




